package com.hq.service.impl;

import com.github.pagehelper.PageInfo;
import com.github.pagehelper.parser.impl.HsqldbParser;
import com.hq.mapper.MassMapper;
import com.hq.pojo.Appointment;
import com.hq.service.MassService;
import com.sun.javafx.collections.MappingChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MassServiceImpl implements MassService {
    @Autowired
    private MassMapper massMapper;

    //    查询所有群众的个人信息
    @Override
    public PageInfo<Appointment> selectAllMass(String username) {
        List<Appointment> list = massMapper.selectAllMass(username);
        return new PageInfo<>(list) ;
    }



    //    预约体检
    @Override
    public Map<String, String> addAppointment(Appointment appointment) {
        int appointment1 = massMapper.addAppointment(appointment);
        Map<String,String> map = new HashMap<>();
      if(appointment1 > 0){
          System.out.println(100);
            map.put("code","200");
            return map;
        } else {
            map.put("code","201");
            return map;
        }

    }




    //    取消体检
    @Override
    public Map<String,String> deleteAppointment(int appointId) {
        int i = massMapper.deleteAppointment(appointId);
        Map<String,String> map = new HashMap<>();
        if(i>0){
            map.put("code","200");
            return  map;
        }else{
            map.put("code","201");
            return  map;
        }

    }
//修改预约信息
    @Override
    public Map<String, String> appointmentEdit(Appointment appointment) {
        Map<String,String> map = new HashMap<>();
        System.out.println(appointment);
        int appointments = massMapper.appointmentEdit(appointment);
        System.out.println(appointments);
        if(appointments>0){
            map.put("msg","修改成功");
            return map;
        }else{
            map.put("msg","修改失败");
            return map;
        }
    }
}
